package io.renren.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.GiftpackagerulemDao;
import io.renren.dto.GiftpackagerulemDTO;
import io.renren.entity.GiftpackagerulemEntity;
import io.renren.entity.JoinmembermEntity;
import io.renren.service.GiftpackagerulemService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * ${comments}
 *
 * @author Sen 524227263@qq.com
 * @since 1.0.0 2024-05-30
 */
@Service
public class GiftpackagerulemServiceImpl extends CrudServiceImpl<GiftpackagerulemDao, GiftpackagerulemEntity, GiftpackagerulemDTO> implements GiftpackagerulemService {

    @Override
    public QueryWrapper<GiftpackagerulemEntity> getWrapper(Map<String, Object> params) {
        String id = (String) params.get("id");

        QueryWrapper<GiftpackagerulemEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public GiftpackagerulemEntity findNameByGiftPackageRuleMOID(String giftpackagerulemFk) {
        List<GiftpackagerulemEntity> list = this.baseDao.selectList(
                new QueryWrapper<GiftpackagerulemEntity>()
                        .select("GiftPackageName")
                        .eq("GiftPackageRuleMOID", giftpackagerulemFk));
        return list.size() > 0 ? list.get(0) : null;
    }
}